class Chapter {
  int? id;
  final int bookId;
  final String title;
  final String? content;

  Chapter({this.id, required this.bookId, required this.title, this.content});

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'book_id': bookId,
      'title': title,
      'content': content,
    };
  }

  factory Chapter.fromMap(Map<String, dynamic> map) {
    return Chapter(
      id: map['id'],
      bookId: map['book_id'],
      title: map['title'],
      content: map['content'],
    );
  }

  @override
  String toString() => 'Chapter(id:$id, bookId:$bookId, title:$title)';
}